﻿
using BCGM.MedicalWisdom.IServices;
using BCGM.MedicalWisdom.Model.Models;
using BCGM.MedicalWisdom.Services.BASE;
using BCGM.MedicalWisdom.Repository.BASE;
using System.Threading.Tasks;
using System.Collections.Generic;
using BCGM.MedicalWisdom.Model.ViewModels.Order;
using SqlSugar;

namespace BCGM.MedicalWisdom.Services
{
    public class DrugSKUServices : BaseServices<DrugSKU>, IDrugSKUServices
    {
        private readonly IBaseRepository<DrugSKU> _dal;
        public DrugSKUServices(IBaseRepository<DrugSKU> dal)
        {
            this._dal = dal;
            base.BaseDal = dal;
        }

        public async Task<List<DrugSKUOutputDto>> GetDrugSKUOutputsSql()
        {
            string sql = "select * from DrugSKU where IsDeleted = 0;";
            SugarParameter[] parameters = null;
            var list = await base.BaseDal.QuerySql(sql, parameters);
            List<DrugSKUOutputDto> drugSKUs = new List<DrugSKUOutputDto>();
            foreach (var param in list)
            {
                drugSKUs.Add(new DrugSKUOutputDto
                {
                    DrugSkuId = param.DrugSkuId,
                    DrugSkuName = param.DrugSkuName,
                    DrugSkuNum = param.DrugSkuNum,
                    Deletedby = param.Deletedby,
                    DeletedTime = param.DeletedTime,
                    Updatedby = param.Updatedby,
                    UpdatedTime = param.UpdatedTime,
                    Createdby = param.Createdby,
                    CreatedTime = param.CreatedTime,
                    IsDeleted = param.IsDeleted,
                    DrugSkuPrice = param.DrugSkuPrice,
                });
            }
            return drugSKUs;
        }
    }
}